public class TreeNode {
    //静态二叉树
    private TreeNode leftNode;
    private TreeNode rightNode;
    private int data;

    public TreeNode(int data){
        this.data=data;
    }

    public TreeNode getLeftNode() {
        return leftNode;
    }

    public void setLeftNode(TreeNode leftNode) {
        this.leftNode = leftNode;
    }

    public TreeNode getRightNode() {
        return rightNode;
    }

    public void setRightNode(TreeNode rightNode) {
        this.rightNode = rightNode;
    }

    public int getData() {
        return data;
    }

    public void setData(int data) {
        this.data = data;
    }

    /**
     * 先序遍历，根->左->右
     */
    public static void PreTreverseTree(TreeNode node){
        if (node!=null){
            System.out.println(node.getData());
            PreTreverseTree(node.getLeftNode());
            PreTreverseTree(node.getRightNode());
        }
    }

    /**
     * 中序遍历，左->根->右
     */
    public static void MidTreverseTree(TreeNode node){
        if (node!=null){
            MidTreverseTree(node.getLeftNode());
            System.out.println(node.getData());
            MidTreverseTree(node.getRightNode());
        }
    }

    /**
     * 后序遍历，左->右->根
     */
    public static void AftTreaverseTree(TreeNode node){
        if (node!=null){
            AftTreaverseTree(node.leftNode);
            AftTreaverseTree(node.rightNode);
            System.out.println(node.getData());
        }
    }

}
